//
//  DragView.m
//  xy_check
//
//  Created by cherry on 10-10-4.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "DragView.h"
#import "xy_checkViewController.h"

@implementation DragView
@synthesize location;
@synthesize parent;

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
	CGPoint pt = [[touches anyObject] locationInView:self];
	location = pt;
	//[[self superview] bringSubviewToFront:self];
}

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
	CGPoint pt = [[touches anyObject] locationInView:self];
	CGRect frame = [self frame];
	frame.origin.x += pt.x - location.x;
	frame.origin.y += pt.y - location.y;
	[self setFrame:frame];
	self.parent.message.text = [NSString stringWithFormat:@"(%0.0f,%0.0f) --> (%0.0f,%0.0f)",frame.origin.x,frame.origin.y,frame.origin.x+frame.size.width,frame.origin.y+frame.size.height];
}

@end
